#include "widget.h"
#include "ui_widget.h"
#include <QLabel>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    QLabel* label = new QLabel(ui->tab);
    label->setText("这是标签页1");

    QLabel* label_2 = new QLabel(ui->tab_2);
    label_2->setText("这是标签页2");
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_add_clicked()
{
    int count = ui->tabWidget->count();
    QWidget* widget = new  QWidget();
    ui->tabWidget->addTab(widget,QString("Tab ")+QString::number(count+1));
    QLabel* label = new QLabel(widget);
    label->setText(QString("这是标签页")+QString::number(count+1));
    ui->tabWidget->setCurrentIndex(count);
}

void Widget::on_pushButton_del_clicked()
{
    int index = ui->tabWidget->currentIndex();
    ui->tabWidget->removeTab(index);
}
